//
//  YeeLoginViewModel.m
//  YeeShopProject
//
//  Created by CoderYee on 2017/3/8.
//  Copyright © 2017年 CoderYee. All rights reserved.
//

#import "YeeLoginViewModel.h"
@implementation YeeLoginViewModel

-(void)bindViewModel
{
    
    RACSignal *phoneSignal=RACObserve(self, self.phoneString);
    RACSignal *pwdSignal=RACObserve(self, self.pwdString);
    
    _loginneableSignal=[RACSignal combineLatest:@[phoneSignal,pwdSignal] reduce:^id (NSString *phoneVail,NSString *pwdVail)
    {
        //NSLog(@"yuwei%@",phoneVail);
        return @([NSString isMobileNumber:phoneVail]&&pwdVail.length>6);
    }];
    
    _command=[[RACCommand alloc] initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input)
    {
        RACSignal *loginSignal=[RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber)
            {
            //这里请求数据
                [subscriber sendNext:nil];
                [subscriber sendCompleted];
             return nil;
          }];
        //可返回后台数据
         return loginSignal;
    }];
    
}
@end
